﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Portal.Xml.Utility;

namespace Portal.Systems.Model
{
    public class GroupRoleCls
    {
        public string GroupRoleId;
        public string GroupRoleName;
        public int SortIndex;
        public RoleCls[] Roles = new RoleCls[0];
    }

    public class GroupRoleParser
    {
        public static GroupRoleCls CreateInstance()
        {
            //tao 1 class trang....
            GroupRoleCls oGroupRoleCls = new GroupRoleCls();
            return oGroupRoleCls;
        }

        public static GroupRoleCls ParseFromXml(string XmlData)
        {
            DataSet ds = XmlUtility.GetDataSetFromXml(XmlData);
            GroupRoleCls oGroupRoleCls = ParseFromDataRow(ds.Tables[0].Rows[0]);
            return oGroupRoleCls;
        }


        public static GroupRoleCls ParseFromDataRow(DataRow dr)
        {
            GroupRoleCls OGroupRoleCls = new GroupRoleCls();
            OGroupRoleCls.GroupRoleId = (string)dr["GroupRoleId"];
            OGroupRoleCls.GroupRoleName = (string)dr["GroupRoleName"];
            OGroupRoleCls.SortIndex = (int)dr["SortIndex"];
            return OGroupRoleCls;
        }

        public static GroupRoleCls[] ParseFromDataTable(DataTable dtTable)
        {
            GroupRoleCls[] GroupRoles = new GroupRoleCls[dtTable.Rows.Count];
            for (int iIndex = 0; iIndex < dtTable.Rows.Count; iIndex++)
            {
                GroupRoles[iIndex] = ParseFromDataRow(dtTable.Rows[iIndex]);
            }

            return GroupRoles;
        }
    }
}


